-
Notifications
You must be signed in to change notification settings - Fork 13.7k
server : add try..catch to places not covered by set_exception_handler #11620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
examples/server/server.cpp
Outdated
| try { | ||
| LOG_INF("request: %s %s %s %d\n", req.method.c_str(), req.path.c_str(), req.remote_addr.c_str(), res.status); | ||
|
|
||
| LOG_DBG("request: %s\n", req.body.c_str()); | ||
| LOG_DBG("response: %s\n", res.body.c_str()); | ||
| LOG_DBG("request: %s\n", req.body.c_str()); | ||
| LOG_DBG("response: %s\n", res.body.c_str()); | ||
| } catch (const std::exception & e) { | ||
| LOG_ERR("failed to log request/response: %s\n", e.what()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do any of these throw?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but this is mostly for future-proof.
Indeed, I was a bit doubt when adding this try..catch because I want to communicate to whoever in the future touching this code that "exception is not handled here". Another solution is to just add a TODO, but not sure if it's enough because people may not even read it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's fine to remove the try/catch if it is not currently used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I replaced the try catch with a comment
ggml-org#11620) * server : add try..catch to places not covered by set_exception_handler * log_server_request: rm try catch, add reminder
ggml-org#11620) * server : add try..catch to places not covered by set_exception_handler * log_server_request: rm try catch, add reminder
ggml-org#11620) * server : add try..catch to places not covered by set_exception_handler * log_server_request: rm try catch, add reminder
ggml-org#11620) * server : add try..catch to places not covered by set_exception_handler * log_server_request: rm try catch, add reminder
For httplib, the exceptions inside
set_exception_handlerandset_loggerare not being handled